package com.alks.function.controller.procurement;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.SysLogAop;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.dto.procurement.PcPackDetailDto;
import com.alks.function.data.request.procurement.BatchProcessNotOrderMaterialRequest;
import com.alks.function.data.request.procurement.NewPcPackDetailRequest;
import com.alks.function.data.request.procurement.NotOrderMaterialRequest;
import com.alks.function.data.request.procurement.PcPackDetailRequest;
import com.alks.function.service.procurement.PackagOrderingOperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@ApiRestController("/PackagOrderingOperation")
@Slf4j
@Api(value = "包材订购作业", tags = {
        "采购部-包材订购作业"})
@RoleCheck(prgIds = {"150108"})
public class PackagOrderingOperationController {

    @Autowired
    private PackagOrderingOperationService materialOrderingOperationService;

    @WebLogger
    @PostMapping("/getNotOrderMaterialList")
    @ApiOperation(value = "指令包材 待订购明细-查询",tags = "采购部-包材订购作业")
    public ResponseInfo getNotOrderMaterialList(@RequestBody NotOrderMaterialRequest request){
        return materialOrderingOperationService.getNotOrderMaterialList(request);
    }

    @WebLogger
    @PostMapping("/getNotOrderMaterialTotalPurQty")
    @ApiOperation(value = "指令包材待订购明细-合计",tags = "采购部-包材订购作业")
    public ResponseInfo getNotOrderMaterialTotalPurQty(@RequestBody NotOrderMaterialRequest request){
        return materialOrderingOperationService.getNotOrderMaterialTotalPurQty(request);
    }

    @WebLogger
    @PostMapping("/updateNotOrderMaterial")
    @ApiOperation(value = "待订购明细编辑",tags = "采购部-包材订购作业")
    public ResponseInfo updateNotOrderMaterial(@RequestBody PcPackDetailDto request){
        return materialOrderingOperationService.updateNotOrderMaterial(request);
    }

    @WebLogger
    @PostMapping("/getOrderedDetailsList")
    @ApiOperation(value = "已订购明细-查询",tags = "采购部-包材订购作业")
    public ResponseInfo getOrderedDetailsList(@RequestBody NotOrderMaterialRequest request){
        return materialOrderingOperationService.getOrderedDetailsList(request);
    }

    @SysLogAop
    @WebLogger
    @PostMapping("/updateOrderedRemark")
    @ApiOperation(value = "已订购明细-批量更新（备注）",tags = "采购部-包材订购作业")
    public ResponseInfo updateOrderedRemark(@RequestBody List<PcPackDetailRequest> request){
        return materialOrderingOperationService.updateOrderedRemark(request);
    }

    @WebLogger
    @PostMapping("/updateReqDateAndUPrice")
    @ApiOperation(value = "修改需求日期/单价",tags = "采购部-包材订购作业")
    public ResponseInfo updateReqDateAndUPrice(@RequestBody NewPcPackDetailRequest request){
        return materialOrderingOperationService.updateReqDateAndUPrice(request);
    }

    @WebLogger
    @PostMapping("/getBatchProcess")
    @ApiOperation(value = "勾选待订购",tags = "采购部-包材订购作业")
    public ResponseInfo getBatchProcess(@RequestBody BatchProcessNotOrderMaterialRequest request){
        return materialOrderingOperationService.getBatchProcess(request);
    }

    @WebLogger
    @PostMapping("/cancelOrderedDetails")
    @ApiOperation(value = "订购单取消",tags = "采购部-包材订购作业")
    public ResponseInfo cancelOrderedDetails(@RequestBody List<PcPackDetailRequest> request){
        return materialOrderingOperationService.cancelOrderedDetails(request);
    }
    @WebLogger
    @PostMapping("/makePurchaseOrder")
    @ApiOperation(value = "生成订购单",tags = "采购部-包材订购作业")
    public ResponseInfo makePurchaseOrder(@RequestBody List<PcPackDetailRequest> request){
        return materialOrderingOperationService.makePurchaseOrder(request);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrder")
    @ApiOperation(value = "导出订购单",tags = "采购部-包材订购作业")
    public void exportPurchaseOrder(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        materialOrderingOperationService.exportPurchaseOrder(request,response);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrderByLongitudinal")
    @ApiOperation(value = "导出订购单(分段/纵)",tags = "采购部-包材订购作业")
    public void exportPurchaseOrderByLongitudinal(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        materialOrderingOperationService.exportPurchaseOrderByLongitudinal(request,response);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrderByTransverse")
    @ApiOperation(value = "导出订购单(分段/横)",tags = "采购部-包材订购作业")
    public void exportPurchaseOrderByTransverse(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        materialOrderingOperationService.exportPurchaseOrderByTransverse(request,response);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrderByPrefill")
    @ApiOperation(value = "导出订购单(分段/横/预补)",tags = "采购部-包材订购作业")
    public void exportPurchaseOrderByPrefill(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        materialOrderingOperationService.exportPurchaseOrderByPrefill(request,response);
    }
}
